<{include file='customer/head.html'}>
<body>
	<div class="akr_main_inner_bg">
		<div class="wid97 inforBar">
			<input type="text" name="name" value="" class="inputText">
			<button onclick="ajaxpage()" class="akrBtn blue">搜索</button>
			<button onclick="add()" class="akrBtn blue">+&nbsp;添加</button>
		</div>
		<table class="akrTable akrTable_border">
			<thead>	
				<tr>
					<th>id</th>
					<th>名称</th>
					<th>星级</th>
					<th>备注</th>
					<th>添加时间</th>
					<th>负责销售</th>
					<th>销售对接时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody class="listUl">
				<{foreach from=$list item=vo}>
					<tr>
						<td><{$vo.id}></td>
						<td><{$vo.name}></td>
						<td><{$vo.star}></td>
						<td><textarea readonly class="des"><{$vo.remark}></textarea></td>
						<td><{$vo.addtime|date_format:"%Y-%m-%d<br>%H:%M:%S"}></td>
						<td><{$vo.displayname}></td>
						<td><{$vo.updatetime|date_format:"%Y-%m-%d<br>%H:%M:%S"}></td>
						<td>
							<span class="spanBtn" onclick="edit(<{$vo.id}>)">编辑</span>
							<span class="spanBtn" onclick="del(<{$vo.id}>)">删除</span>
						</td>
					</tr>
				<{/foreach}>
			</tbady>
		</table>
		<{if trim($pageshow)!=''}>
			<div class="page"><{$pageshow}></div>
		<{/if}>
	</div>
	<script type="text/javascript">
		function add(){
			_layer_admin.open('添加客户','../CustomerIndex/add',"50%","70%");
		}
		function edit(id){
			_layer_admin.open('编辑客户','../CustomerIndex/edit?id='+id,"50%","70%");
		}
		function del(id){
			_layer_admin.confirm('确认删除吗?',function(index){
				_ajaxs.post('../CustomerIndex/del','id='+id,function(data){
					if(data.status){
						_layer_admin.successMsg(data.message,function(){
							var page=$(".current").text();
							ajaxpage(page,"");
						});
					}else{
						_layer_admin.errorMsg(data.message);
					}
				})
			})
		}
		$("#choiceword").on('click',function(){
			ajaxpage();
		});
		function getvar(){
			var newurl='';
			var searchword=$('input[name="name"]').val();
			if(searchword!=''){
				newurl+="name="+searchword;
			}
			return newurl;
		}
		function ajaxpage(page,newurl=""){
			var url=getvar();
			if(page){
				if(url!=''){
					url+="&page="+page;
				}else{
					url+="page="+page;
				}
			}
			var href='../CustomerIndex/lists';
			_ajaxs.post(href,url,function _return(data){
					$('.listUl').html('');
					$('.listUl').html(data.data.list);
					if(data.data.pageshow){
						$('.page').html(data.data.pageshow);
					}else{
						$('.page').html('');
					}
			})
		}
	</script>
</body>
</html>